package com.cxyzy.demo.property_anims

import android.animation.ObjectAnimator
import android.os.Bundle
import android.view.animation.Animation
import androidx.appcompat.app.AppCompatActivity
import com.cxyzy.demo.R
import kotlinx.android.synthetic.main.activity_p_color.*


/**
 * 动画样例：改变颜色
 */
class PColorActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_p_color)
        initView()
    }

    private fun initView() {
        button.setOnClickListener { anim() }
    }

    private fun anim() {
        val animator = ObjectAnimator.ofArgb(textView, "textColor", -0x10000, -0xff0100)
        animator.duration = 500
        animator.repeatCount = Animation.INFINITE
        animator.start()
    }
}
